package com.example.crystal.trippers.adaper;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;
import java.util.Objects;

/**
 * Created by crystal on 2016/11/10.
 *
 * viewpager屏幕适配器
 * 用于实现控件的滚动功能
 * 由于不需要屏幕翻转，本例中使用pageadapter
 *
 */

public class ContentAdapter extends PagerAdapter{

    private List<View> viewList;

    public ContentAdapter(List<View> views)
    {
        this.viewList = views;
    }

    @Override
    public int getCount(){
        return viewList.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1)
    {
        return arg0 == arg1;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position)
    {
        View view = viewList.get(position);
        container.addView(view);

        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object)
    {
        container.removeView(viewList.get(position));
    }
}
